// --------------------------------------查看详情功能及处理回显功能--------------------------------------------------------------
$.get("/typelist")
    .done(list=>{
        list.forEach(function (Sertype) {
            var opt= $("<option/>");
            opt.val(Sertype.serviceId);
            opt.text(Sertype.serviceNames);
            opt.appendTo("#See [name=leixing]");
        })
    });
$.get("/staYglist")
    .done(list=>{
        list.forEach(function (stayg) {
            var opt= $("<option/>");
            opt.val(stayg.empId);
            opt.text(stayg.empName);
            opt.appendTo("#fenpei [name=processedMan]");
        })
    });
function actionFormatter(){
    var del=`<button class="aaa btn btn-danger "><i class="glyphicon glyphicon-eye-open"></i>查看</button> `;
    var edit=`<button class="cc btn btn-warning"><i class="glyphicon glyphicon-user"></i>处理</button>`
    var fankui=`<button class="nn btn btn-info"><i class="glyphicon glyphicon-user"></i>反馈</button>`
    return del+edit+fankui;
}
var actionEvents = {
    "click .aaa": function (a, b, row) {
        $("#See [name=name]").html(row.serviceName);
        $("#See [name=kehu]").html(row.customer.name);
        $("#See [name=leixing]").html(row.servicetype.serviceNames);
        $("#See [name=phone]").html(row.customer.cellphone);
        $("#See [name=neirong]").html(row.serviceContent);
        $("#See [name=beizhu]").html(row.note);
        $("#See").dialog("show");

    },
    "click .cc": function (a, b, row) {
        $("#caozuo [name=serviceId]").val(row.serviceId);
        $("#caozuo [name=name]").html(row.serviceName);
        $("#caozuo [name=start]").html(row.fuwustart.fuwuleixing);
        $("#caozuo [name=leixing]").html(row.servicetype.serviceNames);
        $("#caozuo [name=chuangjianren]").html(row.staff.empName);
        $("#caozuo [name=chuangjianshijian]").html(row.lastModifyTime);
        $("#caozuo [name=daichuli]").html(row.staff.empName);
        $("#caozuo [name=neirong]").html(row.serviceContent);
        $("#caozuo").dialog("show");
    },
    "click .nn": function (a, b, row) {
        $("#fankui [name=serviceId]").val(row.serviceId);
        $("#fankui [name=name]").html(row.serviceName);
        $("#fankui [name=start]").html(row.fuwustart.fuwuleixing);
        $("#fankui [name=leixing]").html(row.servicetype.serviceNames);
        $("#fankui [name=chuangjianren]").html(row.staff.empName);
        $("#fankui [name=chuangjianshijian]").html(row.lastModifyTime);
        $("#fankui [name=daichuli]").html(row.staff.empName);
        $("#fankui [name=neirong]").html(row.serviceContent);
        $("#fankui").dialog("show");
    }
}
$("#See").dialog({
    title:"查看服务详情",
    width:"100%",
})
$("#caozuo").dialog({
    title:"处理操作",
    btnBind(){
        var params=$("#caozuo form").serialize();
        $.get(`${ctx}/updatechuli`,params)
            .done(msg=>{
                toastr.success(msg);
                $("#serTb").bootstrapTable("refresh");
                $("#caozuo").dialog("hide");
            })
    }
})
$("#fankui").dialog({
    title:"反馈操作",
    btnBind(){
        var params=$("#fankui form").serialize();
        $.get(`${ctx}/updatefankui`,params)
            .done(msg=>{
                toastr.success(msg);
                $("#serTb").bootstrapTable("refresh");
                $("#fankui").dialog("hide");
            })
    }
})

// -----------------------------------------以下是条件查询---------------------------------------------------
function chaxun() {
    var formParams=$("#queryForm").serialize();
    var obj=Qs.parse(formParams);
    $("#serTb").bootstrapTable("refresh",{query:obj});

}
// -----------------------------以下是条件查询绑定状态和类型下拉框的值-------------------------------------------------
$.get("/typelist")
    .done(list=>{
        list.forEach(function (Sertype) {
            var opt= $("<option/>");
            opt.val(Sertype.serviceId);
            opt.text(Sertype.serviceNames);
            opt.appendTo("#queryForm [name=fuwuid]");
        })
    });
$.get("/startlist")
    .done(list=>{
        list.forEach(function (start) {
            var opt= $("<option/>");
            opt.val(start.fuwuid);
            opt.text(start.fuwuleixing);
            opt.appendTo("#queryForm [name=serviceId]");
        })
    });
// -----------------------------以下是处理、反馈结果绑定下拉框的值-------------------------------------------------
$.get("/startlist")
    .done(list=>{
        list.forEach(function (start) {
            var opt= $("<option/>");
            opt.val(start.fuwuid);
            opt.text(start.fuwuleixing);
            opt.appendTo("#caozuo [name=status]");
        })
    });
$.get("/startlist")
    .done(list=>{
        list.forEach(function (start) {
            var opt= $("<option/>");
            opt.val(start.fuwuid);
            opt.text(start.fuwuleixing);
            opt.appendTo("#fankui [name=status]");
        })
    });